#!/usr/bin/env python
"""
# -*- coding: utf-8 -*-
# @Time    : 2020/9/18 13:21
# @Author  : AshJo
# @Desc    : 面向对象编程1
# @Filename: obj_program1.py
# @Version : v1.0
"""

from math import pi


# 先定义一个模子，用来描述一类事物
# 具有相同的属性和动作

# 类的创建
class Person:  # 类名
    def __init__(self, name, sex, job, hp, weapon, ad):
        """
        必须叫__init__这个名字，不能改变的，所有的在一个具体的人物出现之后拥有的属性,
        都可以写在这里
        """
        self.name = name
        self.sex = sex
        self.job = job
        self.level = 0
        self.hp = hp
        self.weapon = weapon
        self.ad = ad


class Dog:
    def __init__(self, name, type, hp, ad):
        self.name = name
        self.type = type
        self.hp = hp
        self.ad = ad


class Circular:
    def __init__(self, radius):
        self.radius = radius

    def area(self):
        return pi * (self.radius ** 2)

    def perimeter(self):
        return 2 * pi * self.radius


class User:
    def __init__(self, username, password):
        self.username = username
        self.password = password


c = Circular(5)
print('圆形面积：%.1f' % c.area())
print('圆形周长：%.1f' % c.perimeter())

c.radius = 10
print('圆形面积：%.1f' % c.area())
print('圆形周长：%.1f' % c.perimeter())
user1 = User('Tom', 123456)
user2 = User('Jerry', 654321)
print(user1.__dict__)
print(user2.__dict__)

小白 = Dog('cindy', '吉娃娃', 50, 9)
print(小白, 小白.__dict__)

# 类名()会自动调用类中的__init__方法

# cleverlove是对象，cleverlove = Person()的过程是通过一个类获取一个对象的过程 - 类的实例化
cleverlove = Person('cleverlove', '男', '打野', 250, '养猪', 1)
print(cleverlove, cleverlove.__dict__)

uzi = Person('uzi', '男', '射手', 300, '洗澡', 99)
print(uzi, uzi.__dict__)

# 属性的查看
print(uzi.weapon)  # = print(uzi.__dict__['weapon'])

# 属性的修改
uzi.ad = 99 + 1
print(uzi.ad)

# 属性的添加
uzi.money = 100000
print(uzi.__dict__)

# 属性的删除
del uzi.money
print(uzi.__dict__)
